package com.example.springboot.controller;

import com.example.springboot.config.MyConfig;
import com.example.springboot.config.UserConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: ConfigController
 * @Author wenlinyu
 * @Date: 2020/12/15 11:09
 * @Version 1.0
 */
@RestController
public class ConfigController {

    private Logger logger = LoggerFactory.getLogger(ConfigController.class);

    @Value("${user.id}")
    private String userId;

    @Value("${user.email}")
    private String email;

    @Autowired
    private UserConfig userConfig;

    @Autowired
    private MyConfig myConfig;

    @GetMapping("/index")
    public String index() {
        logger.debug("/index debug...");
        logger.info("/index info...");
        return "index  user.id: " + userId + ", user.email: " + email;
    }

    @GetMapping("/index2")
    public String index2() {
        return "index2 user.id: " + userConfig.getId() + ", user.email: " + userConfig.getEmail();
    }

    @GetMapping("/index3")
    public String index3() {
        return "index3 user.id: " + myConfig.getId() + ", user.email: " + myConfig.getEmail();
    }
}
